/**
 * @(#)ApkConfigController.java 2017年03月1日
 * Copyright(C) 2017 ZHEXIN IT CO.,LTD. All rights reserved.
 */
package org.jsbd.boss.action;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.jsbd.boss.domian.BruchTaskBean;
import org.jsbd.boss.service.IBruchTaskService;

import org.jsbd.boss.common.DataGridModel;
import org.jsbd.boss.common.ResponseMapUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;


@Controller
@RequestMapping("/bruchTask")
public class BruchTaskController{

	private static final Logger LOGGER=LoggerFactory.getLogger(BruchTaskController.class);
	
	@Autowired
	private IBruchTaskService bruchTaskService;

	/**
	 * 列表页面
	 * 
	 * @param model
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "listModel")
	public String showBruchTaskList(Model model) throws Exception {
		return "/bruchTask/bruchTaskList";
	}

	@RequestMapping(value = "saveBruchTask")
	@ResponseBody
	public Object saveBruchTask(BruchTaskBean bruchTask){
		bruchTask.setStatus(0);
		bruchTaskService.saveBruchTask(bruchTask);
		return ResponseMapUtils.responseSuccess();
	}

	@RequestMapping(value = "updateBruchTask")
	@ResponseBody
	public Object updateBruchTask(BruchTaskBean bruchTask){
		Map<String, String> resultMap = new HashMap<String, String>();
		if (bruchTask.getId() == null) {
			return ResponseMapUtils.responseFail("参数缺失，请确认参数再提交");
		}
		
		BruchTaskBean condition=new BruchTaskBean();
		condition.setId(bruchTask.getId());
		BruchTaskBean temp=bruchTaskService.getBruchTask(condition);
		if(temp==null){
			return ResponseMapUtils.responseFail("记录未找到,请重试");
		}
		
		bruchTaskService.updateBruchTask(bruchTask);
		return ResponseMapUtils.responseSuccess();
	}
	
	@RequestMapping(value = "updateBruchTaskStatus")
	@ResponseBody
	public Object updateBruchTaskStatuss(BruchTaskBean bruchTask){
		if (bruchTask.getId() == null) {
			return ResponseMapUtils.responseFail("参数缺失，请确认参数再提交");
		}
		
		bruchTaskService.updateBruchTaskStatus(bruchTask);
		return ResponseMapUtils.responseSuccess();
	}
	

	@RequestMapping(value = "getBruchTask")
	@ResponseBody
	public BruchTaskBean getBruchTask(BruchTaskBean bruchTask) throws Exception {
		return bruchTaskService.getBruchTask(bruchTask);
	}

	@RequestMapping(value = "getBruchTaskList")
	@ResponseBody
	public List<BruchTaskBean> getBruchTaskList(BruchTaskBean bruchTask) throws Exception {
		return bruchTaskService.getBruchTaskList(bruchTask);
	}

	@RequestMapping(value = "getBruchTaskListPage")
	@ResponseBody
	public Map<String, Object> getBruchTaskListPage(DataGridModel page, BruchTaskBean bruchTask) throws Exception {
		return bruchTaskService.getBruchTaskListPage(page, bruchTask);
	}
	
	@RequestMapping(value = "deleteBruchTask")
	@ResponseBody
	public Map<String, Object> deleteBruchTask(BruchTaskBean bruchTask) throws Exception {
		bruchTaskService.deleteBruchTask(bruchTask);
		return ResponseMapUtils.responseSuccess();
	}
	

}
